package com.ruoyi.shop.service.impl;

import java.util.List;

import com.ruoyi.shop.api.RemotePetrolService;
import com.ruoyi.shop.api.domain.ChePetrol;
import com.ruoyi.shop.api.domain.ChePetrolOil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shop.mapper.ChePetrolOilMapper;
import com.ruoyi.shop.service.IChePetrolOilService;

/**
 * 汽油类型Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-01-03
 */
@Service
public class ChePetrolOilServiceImpl implements IChePetrolOilService 
{
    @Autowired
    private ChePetrolOilMapper chePetrolOilMapper;

    @Autowired
    private RemotePetrolService remotePetrolService;

    /**
     * 查询汽油类型
     * 
     * @param id 汽油类型主键
     * @return 汽油类型
     */
    @Override
    public ChePetrolOil selectChePetrolOilById(Long id)
    {
        return chePetrolOilMapper.selectChePetrolOilById(id);
    }

    /**
     * 查询汽油类型列表
     * 
     * @param chePetrolOil 汽油类型
     * @return 汽油类型
     */
    @Override
    public List<ChePetrolOil> selectChePetrolOilList(ChePetrolOil chePetrolOil)
    {
        List<ChePetrolOil> chePetrolOils = chePetrolOilMapper.selectChePetrolOilList(chePetrolOil);
        for (ChePetrolOil petrolOil : chePetrolOils) {
            ChePetrol info1 = remotePetrolService.getInfo1(petrolOil.getShopId(), null);
            petrolOil.setChePetrol(info1);
        }
        return chePetrolOils;
    }

    /**
     * 新增汽油类型
     * 
     * @param chePetrolOil 汽油类型
     * @return 结果
     */
    @Override
    public int insertChePetrolOil(ChePetrolOil chePetrolOil)
    {
        return chePetrolOilMapper.insertChePetrolOil(chePetrolOil);
    }

    /**
     * 修改汽油类型
     * 
     * @param chePetrolOil 汽油类型
     * @return 结果
     */
    @Override
    public int updateChePetrolOil(ChePetrolOil chePetrolOil)
    {
        return chePetrolOilMapper.updateChePetrolOil(chePetrolOil);
    }

    /**
     * 批量删除汽油类型
     * 
     * @param ids 需要删除的汽油类型主键
     * @return 结果
     */
    @Override
    public int deleteChePetrolOilByIds(Long[] ids)
    {
        return chePetrolOilMapper.deleteChePetrolOilByIds(ids);
    }

    /**
     * 删除汽油类型信息
     * 
     * @param id 汽油类型主键
     * @return 结果
     */
    @Override
    public int deleteChePetrolOilById(Long id)
    {
        return chePetrolOilMapper.deleteChePetrolOilById(id);
    }

    @Override
    public List<ChePetrolOil> selectOilListById(Long id) {
        return chePetrolOilMapper.selectChePetrolOilListById(id);
    }
}
